using Endos.Wodo.Business;
using Microsoft.AspNet.SignalR.Hubs;

namespace Endos.Wodo.Web.Hubs
{
    public class NotifierContext<T> : INotifierContext<T>
        where T : Notifier, new()
    {
        private readonly IHubConnectionContext _hubConnectionContext;

        public NotifierContext(IHubConnectionContext hubConnectionContext)
        {
            _hubConnectionContext = hubConnectionContext;
        }

        public T All
        {
            get
            {
                return new T { Client = _hubConnectionContext.All };
            }
        }

        public T AllExcept(params string[] excludeConnectionIds)
        {
            return new T { Client = _hubConnectionContext.AllExcept(excludeConnectionIds) };
        }

        public T Client(string connectionId)
        {
            return new T { Client = _hubConnectionContext.Client(connectionId) };
        }

        public T Group(string groupName, params string[] excludeConnectionIds)
        {
            return new T { Client = _hubConnectionContext.Group(groupName, excludeConnectionIds) };
        }
    }
}